package com.csp.app.service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.csp.app.client.ServiceClient;
import com.csp.app.entity.Exam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

@Service
public class ExamService {
    @Autowired
    private ServiceClient serviceClient;

    public List<Exam> searchAll() {
        return serviceClient.searchAllExam();
    }


    /**
     * 添加考试
     *
     * @param exam
     * @return
     */
    public boolean add(Exam exam) {
        return serviceClient.addExam(exam);
    }

    /**
     * 批量添加考试
     *
     * @param exams
     * @return
     */
    public boolean batchAdd(List<Exam> exams) {
        return serviceClient.batchAddExam(exams);
    }

    /**
     * 通过考试组查询考试
     *
     * @param groupId
     * @return
     */
    public List<Exam> getExamsByGroupId(Integer groupId) {
        return serviceClient.getExamsByGroupId(groupId);
    }

    public Integer selectCount(EntityWrapper<Exam> wrapper) {
        return serviceClient.selecExamCout(wrapper);
    }

    public Page<Exam> selectPage(Page<Exam> page, EntityWrapper<Exam> wrapper) {
        return serviceClient.selectExamPage(page, wrapper);
    }

    public Exam getEntityFromCacheByKey(String key){
        return serviceClient.getExamFromCacheByKey(key);
    }
}
